package com.zx.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.fastjson.JSON;
import com.zx.config.OrderServiceBlockHandler;
import com.zx.config.OrderServiceFallback;
import com.zx.entity.Order;
import com.zx.entity.Product;
import com.zx.feign.ProductFeignClient;
import com.zx.mapper.OrderMapper;
import com.zx.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author jack.wu
 * @version 1.0
 * @date 2020-03-08
 */
@Slf4j
@Service
public class OrderServiceImpl1 {

    /**
     * 定义资源
     * blockHandler 定义当资源内部发送blockException进入的方法 捕获sentinel定义的异常
     * fallback     定义当资源内部发送Throwable进入的方法
     * 方法的返回值和参数都应该一致，参数后面加上异常
     *
     * @return
     */
//    @SentinelResource(value = "message", blockHandler = "blockHandlerMethod", fallback = "fallbackMethod")
    @SentinelResource(value = "message", blockHandlerClass = OrderServiceBlockHandler.class,
            fallbackClass = OrderServiceFallback.class)
    public String message() {
        return "message";
    }


}
